package com.belle.sfsdfasdfsdf.domain;


import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;

@Entity
@Table(name = "job_info")
@IdClass(ScheduleJob.PrimaryKey.class)
public class ScheduleJob {
	
	@Id
	/** 任务名称 */
	private String jobName;
	
	@Id
	/** 任务分组 */
	private String jobGroup;
	
	
	/** 任务状态 0禁用 1启用 2删除*/
	private Integer jobStatus;
	/** 任务运行时间表达式 */
	private String cronExpression;
	/** 任务描述 */
	private String desc;
	
	public String getJobName() {
		return jobName;
	}
	
	public void setJobName(String jobName) {
		this.jobName = jobName;
	}
	
	public String getJobGroup() {
		return jobGroup;
	}
	
	public void setJobGroup(String jobGroup) {
		this.jobGroup = jobGroup;
	}
	
	public Integer getJobStatus() {
		return jobStatus;
	}
	
	public void setJobStatus(Integer jobStatus) {
		this.jobStatus = jobStatus;
	}
	
	public String getCronExpression() {
		return cronExpression;
	}
	
	public void setCronExpression(String cronExpression) {
		this.cronExpression = cronExpression;
	}
	
	public String getDesc() {
		return desc;
	}
	
	public void setDesc(String desc) {
		this.desc = desc;
	}
	
	@Override
	public String toString() {
		return "ScheduleJob{" +
				"jobName='" + jobName + '\'' +
				", jobGroup='" + jobGroup + '\'' +
				", jobStatus=" + jobStatus +
				", cronExpression='" + cronExpression + '\'' +
				", desc='" + desc + '\'' +
				'}';
	}
	
	public static class PrimaryKey implements Serializable {
		
		@Column(nullable = false)
		private String jobName;
		
		@Column(nullable = false)
		private String jobGroup;
		
		public String getJobName() {
			return jobName;
		}
		
		public void setJobName(String jobName) {
			this.jobName = jobName;
		}
		
		public String getJobGroup() {
			return jobGroup;
		}
		
		public void setJobGroup(String jobGroup) {
			this.jobGroup = jobGroup;
		}
		
		@Override
		public boolean equals(Object o) {
			if(this == o)
				return true;
			if(o == null || getClass() != o.getClass())
				return false;
			PrimaryKey that = (PrimaryKey) o;
			return Objects.equals(getJobName(), that.getJobName()) &&
					Objects.equals(getJobGroup(), that.getJobGroup());
		}
		
		@Override
		public int hashCode() {
			return Objects.hash(getJobName(), getJobGroup());
		}
	}
}
